﻿using BCCommon;
using BCCommon.Enums;
using BCDto.Common.SystemExceptionRecord;
using BCService.Common.ExceptionService;
using Microsoft.AspNetCore.Mvc;
using System;

namespace BCTMSRESTful.Controllers.Management.ExceptionRecords
{
    [ApiExplorerSettings(GroupName = "Admin-SystemTools")]
    [Route("api/v1/sim/[controller]")]
    public class SystemExceptionRecordsController : ManagementBaseController
    {
        private readonly ISystemExceptionRecordService systemExceptionRecordService;

        public SystemExceptionRecordsController(ISystemExceptionRecordService systemExceptionRecordService)
        {
            this.systemExceptionRecordService = systemExceptionRecordService;
        }

        /// <summary>
        /// 获取系统异常信息（分页）
        /// </summary>
        /// <param name="name">异常名称</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">开始时间</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="ascending">升序</param>
        /// <param name="index">当前页</param>
        /// <param name="size">每页条数</param>
        /// <response code="200">带有分页信息的系统异常信息列表。</response>
        /// <response code="401">请求需要认证或者认证信息已过期。</response>
        /// <returns></returns>
        [HttpGet]
        [ProducesResponseType(typeof(PageableList<SystemExceptionRecordDto>), 200)]
        public IActionResult Get([FromQuery(Name = "name")]string name,
            [FromQuery(Name = "start")]DateTime? start,
            [FromQuery(Name = "end")]DateTime? end,
            [FromQuery(Name = "sort_name")]string sortName,
            [FromQuery(Name = "ascending")]bool? ascending,
            [FromQuery(Name = "index")]int index = 1,
            [FromQuery(Name = "size")]int size = 10)
        {
            return this.Ok(this.systemExceptionRecordService.GetSystemExceptionRecords(name, start, end, sortName, ascending, index, size));
        }
        ///// <summary>
        ///// 获取App异常信息（分页）
        ///// </summary>
        ///// <param name="handleStatus">处理状态，默认仅查询待处理</param>
        ///// <param name="index">当前页码</param>
        ///// <param name="size">每页显示的数据条数。</param>
        ///// <response code="200">带有分页信息的App异常信息列表。</response>
        ///// <response code="401">请求需要认证或者认证信息已过期。</response>
        ///// <returns></returns>
        //[HttpGet("app/[action]")]
        //[ProducesResponseType(typeof(PageableList<AppExceptionRecordDto>), 200)]
        //public IActionResult Query([FromQuery(Name = "handle_status")]AppExceptionHandleStatus? handleStatus,
        //    [FromQuery(Name = "index")]int index = 1, [FromQuery(Name = "size")]int size = 10)
        //{
        //    if (!handleStatus.HasValue)
        //    {
        //        handleStatus = AppExceptionHandleStatus.Pending;
        //    }
        //    return this.Ok(this.exceptionRecordService.GetAppExceptionRecords(handleStatus.Value,index, size));
        //}
    }
}
